// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.network.packets.hit;

import java.nio.ByteBuffer;
import zombie.characters.IsoPlayer;
import zombie.core.network.ByteBufferWriter;
import zombie.core.raknet.UdpConnection;
import zombie.inventory.types.HandWeapon;
import zombie.network.PacketValidator;
import zombie.network.packets.INetworkPacket;
import zombie.vehicles.BaseVehicle;

public class PlayerHitVehiclePacket extends PlayerHitPacket implements INetworkPacket {
    protected final Vehicle vehicle = new Vehicle();

    public PlayerHitVehiclePacket() {
        super(HitCharacterPacket.HitType.PlayerHitVehicle);
    }

    public void set(IsoPlayer wielder, BaseVehicle _vehicle, HandWeapon weapon, boolean isCriticalHit) {
        super.set(wielder, weapon, isCriticalHit);
        this.vehicle.set(_vehicle);
    }

    @Override
    public void parse(ByteBuffer b, UdpConnection connection) {
        super.parse(b, connection);
        this.vehicle.parse(b, connection);
    }

    @Override
    public void write(ByteBufferWriter b) {
        super.write(b);
        this.vehicle.write(b);
    }

    @Override
    public boolean isConsistent() {
        return super.isConsistent() && this.vehicle.isConsistent();
    }

    @Override
    public String getDescription() {
        return super.getDescription() + "\n\tVehicle " + this.vehicle.getDescription();
    }

    @Override
    protected void process() {
        this.vehicle.process(this.wielder.getCharacter(), this.weapon.getWeapon());
    }

    @Override
    public boolean validate(UdpConnection connection) {
        return PacketValidator.checkLongDistance(connection, this.wielder, this.vehicle, PlayerHitVehiclePacket.class.getSimpleName());
    }
}
